﻿using System;

namespace FRS_LIB.Telnet
{
    [Serializable]
    public class TelnetClientException : Exception
    {
        /// <summary>Telnet client exception errors.</summary>
        public enum Errors
        {
            /// <summary>Telnet connection to the device not possible.</summary>
            ConnectionNotPossible,
            /// <summary>Login to the device not possible.</summary>
            LoginNotPossible,
        }

        /// <summary>Gets the error code.</summary>
        public Errors Error { get; private set; }

        /// <summary>Creates an exception.</summary>
        /// <param name="error">The telnet exception error.</param>
        public TelnetClientException(Errors error) : base("Telnet client exception!")
        {
            Error = error;
        }

        /// <summary>Creates an exception with a message.</summary>
        /// <param name="error">The telnet exception error.</param>
        /// <param name="message">String containing message.</param>
        public TelnetClientException(Errors error, string message) : base(message)
        {
            Error = error;
        }

        /// <summary>Creates an exception with a message and a reference to a subsequent exception.</summary>
        /// <param name="error">The telnet exception error.</param>
        /// <param name="message">String containing message.</param>
        /// <param name="innerException">The subsequent exception, which occurence caused the IsolatedStorageManagerException</param>
        public TelnetClientException(Errors error, string message, Exception innerException) : base(message, innerException)
        {
            Error = error;
        }

        /// <summary>Creates a serializable exception</summary>
        /// <param name="info">Serialization information. Will be forwarded to standard exception implementation.</param>
        /// <param name="context">Streaming context. Will be forwarded to standard exception implementation.</param>
        protected TelnetClientException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
        {
            //No exception-specific implementation.
        }
    }
}
